package com.neuedu.mvc.framework;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 项目：      spring-framework
 * 类名:       MyHandlerExceptionResolvers
 * 创建时间：  2024/3/20 13：59
 * 描述 :
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */
@Component
public class MyHandlerExceptionResolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        System.out.println("ex.getClass() = " + ex.getClass());

//        if(exinstanceof ArithmeticException){
//
//        }


        //出现异常的时候 跳转到 一个漂亮的 错误页面
        ModelAndView modelAndView = new ModelAndView("/500");
        return modelAndView;
    }
}
